1 # Building in Windows with MSYS2
2 - This environment does not require installing WSL, which may not be available or would get in the way of other virtualization and/or anti-cheat software
3 - It is also much faster to install and get set up because of its small size(~3.65 GB total after building hex file as of 6.0.0)
4 ## Setting up the environment
5 ### Download and install MSYS2
6 1. For 6.0.0, the last version that works is [20220603](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20220603.exe)
7 - [20220503](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20220503.exe) is also known to work
8 - MSYS2 releases can be viewed at https://repo.msys2.org/distrib/x86_64/
9 - Scroll all the way down for an executable, scroll halfway down for a self-extracting archive
10 1. Open an MSYS2 terminal by running C:\msys64\msys2_shell.cmd
11 1. In the newly opened shell, set up your work path
12 - To paste commands, use "Shift+Insert" or Right-click and select "Paste"
16 ## Downloading and installing dependencies
17 ### Installing other dependencies:
19 pacman -S git ruby make cmake gcc mingw-w64-x86_64-libwinpthread-git unzip wget
21 - Note: If some fails to download, use the following command to install the rest without reinstalling everything:
23 pacman -S git ruby make cmake gcc mingw-w64-x86_64-libwinpthread-git unzip wget --needed
25 ### Download the INAV repository
26 #### Go to the working directory
30 #### Download INAV source code
33 git clone https://github.com/iNavFlight/inav
35 - For [a branch](https://github.com/iNavFlight/inav/branches) or [a tag](https://github.com/iNavFlight/inav/tags):
37 # "release_6.0.0" here can be the name of a branch or a tag
38 git clone --branch release_6.0.0 https://github.com/iNavFlight/inav
40 - If you are internet speed or space restrained, you can also use `--depth 1`, which won't download the whole history, and `--single-branch`, which won't download other branches:
42 git clone --depth 1 --single-branch --branch release_6.0.0 https://github.com/iNavFlight/inav
44 This results in ~302 MB instead of ~468 MB download/install size(as of 6.0.0)
46 1. Create xPack directory:
48 mkdir /c/Workspace/xpack
51 2. Find out which version of xPack you need for your INAV version:
53 # Currently, this is 10.2.1 for 6.0.0 and 10.3.1 for master
54 cat /c/Workspace/inav/cmake/arm-none-eabi-checks.cmake | grep "set(arm_none_eabi_gcc_version" | cut -d\" -f2
56 3. Find the version you need from the [releases page](https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/), then either:
57 - Download the "...-win32-x64.zip" and copy the folder inside, or
58 - Right-click, choose "Copy link address" and paste it into the following commands:
61 # paste the link after "wget"
62 wget https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64.zip
63 # paste the file name after "unzip"
64 unzip xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64.zip
65 # you can delete the zip file after as it is no longer needed
66 rm xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64.zip
68 3. This is important. Put the toolkit first before your path so that it is picked up ahead of any other versions that may be present on your system:
70 export PATH=/c/Workspace/xpack/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin:$PATH
72 ## Building the INAV firmware
73 1. Create the build directory:
75 mkdir /c/Workspace/inav/build
77 2. Go into the build directory:
79 cd /c/Workspace/inav/build
82 - This may take a while. If you only want to test one target, remove the rest of the folders from C:\Workspace\inav\src\main\target\
86 4. Compile the firmware for your flight controller.
90 - The list of available targets in INAV can be found here: https://github.com/inavflight/inav/tree/master/src/main/target
91 - The generated hex file will be in the /c/Workspace/inav/build folder
93 ### *** multiple target patterns. Stop. | Error 2
94 #### Delete everything in the build directory that contains previous runs
95 You can either use file explorer and delete everything inside C:\Workspace\inav\build
98 cd /c/Workspace/inav/build && rm -rf *
100 ### -- could not find arm-none-eabi-gcc
101 #### Redo export PATH, make sure xpack version number is correct:
103 export PATH=/c/Workspace/xpack/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin:$PATH
105 ### make: the '-j' option requires a positive integer argument
106 #### You are using too new version of MSYS2, uninstall and reinstall version [20220603](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20220603.exe) or [20220503](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20220503.exe)